package org.niu.str;

public class ReverseStr {
    public int reverse (int x) {
        // write code here
        boolean flag = false;
        if(x<0){x=-x;flag=true;}
        String s = String.valueOf(x);
        StringBuilder stringBuilder = new StringBuilder();
        for(int i = s.length()-1;i>=0;i--){
            stringBuilder.append(s.charAt(i));
        }
        long x1 = Long.valueOf(stringBuilder.toString());
        if(flag == true) return (int)-x1;
        return (int)x1;
    }
}
